package com.atguigu.spzx.manager.mapper;

import com.atguigu.spzx.common.entity.SysUser;
import com.atguigu.spzx.manager.vo.sysUser.SysUserQueryReqVo;
import com.atguigu.spzx.manager.vo.sysUser.SysUserQueryRespVo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
 * <p>
 * 用户表 Mapper 接口
 * </p>
 *
 * @author flyduck
 * @since 2023-10-25
 */
@Mapper
public interface SysUserMapper extends BaseMapper<SysUser> {

    Page<SysUserQueryRespVo> getUserPageByQuery(@Param("pageParam") Page<SysUser> pageParam, @Param("vo") SysUserQueryReqVo sysUserQueryReqVo);

    /**
     * 根据username查询用户
     * @param username
     * @return
     */
    default SysUser getUserByUsername(String username) {
        QueryWrapper<SysUser> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("username", username);
        return this.selectOne(queryWrapper);
    }
}
